/*
 * @Author: Your name
 * @Date:   2020-11-30 10:40:53
 * @Last Modified by:   Your name
 * @Last Modified time: 2020-11-30 10:40:59
 */
const path = require('path')
const config = require('./src/config')
//  const debug = process.env.NODE_ENV !== 'production'
let proxy = {}
let pathRewrite = {}
pathRewrite['^' + config.apiContextPath] = '/'
proxy[config.apiContextPath] = {
    // 配置跨域
    // target: 'https://xmhmyhkj.cn:443/yuapi/',
    target: 'http://127.0.0.1:3001/',
    pathRewrite: pathRewrite
}

function resolve(dir) {
    return path.join(__dirname, dir)
}

module.exports = {
    //  eslint-loader 是否在保存的时候检查
    lintOnSave: process.env.NODE_ENV !== 'production',
    //  生产环境是否生成 sourceMap 文件
    productionSourceMap: false,
    //  webpack配置
    chainWebpack: cfg => {
        cfg.resolve.alias.set('styles', resolve('src/assets/styles'))
    },
    //  避免默认配置把 node_modules 中的文件排除在 Babel 转译范围以外的问题
    transpileDependencies: ['vue-echarts', 'resize-detector'],
    publicPath: config.publicPath,
    devServer: {
        //  webpack-dev-server 相关配置
        proxy: proxy,
        disableHostCheck: true,
        overlay: {
            warnings: true,
            errors: true
        },
        port: 9999
    }
}
